package com.ruoyi.ams.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.ams.domain.AmsOwnUserAssetAuthority;
import com.ruoyi.ams.domain.vo.ApplyHistoryInifo;
import com.ruoyi.ams.domain.vo.ApplyUnlockAuthVo;
import com.ruoyi.ams.mapper.AmsOwnUserAssetAuthorityMapper;
import com.ruoyi.ams.service.IAmsOwnUserAssetAuthorityService;
import com.ruoyi.common.core.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 物联网资产设备用户权限信息Service业务层处理
 * 
 * @author yfkj
 * @date 2021-10-15
 */
@Service
public class AmsOwnUserAssetAuthorityServiceImpl extends ServiceImpl<AmsOwnUserAssetAuthorityMapper, AmsOwnUserAssetAuthority>  implements IAmsOwnUserAssetAuthorityService
{
    @Autowired
    private AmsOwnUserAssetAuthorityMapper amsOwnUserAssetAuthorityMapper;

    /**
     * 查询物联网资产设备用户权限信息
     * 
     * @param ownUserAssetAuthorityId 物联网资产设备用户权限信息主键
     * @return 物联网资产设备用户权限信息
     */
    @Override
    public AmsOwnUserAssetAuthority selectAmsOwnUserAssetAuthorityByOwnUserAssetAuthorityId(Long ownUserAssetAuthorityId)
    {
        return amsOwnUserAssetAuthorityMapper.selectAmsOwnUserAssetAuthorityByOwnUserAssetAuthorityId(ownUserAssetAuthorityId);
    }

    /**
     * 查询物联网资产设备用户权限信息列表
     * 
     * @param amsOwnUserAssetAuthority 物联网资产设备用户权限信息
     * @return 物联网资产设备用户权限信息
     */
    @Override
    public List<AmsOwnUserAssetAuthority> selectAmsOwnUserAssetAuthorityList(AmsOwnUserAssetAuthority amsOwnUserAssetAuthority)
    {
        return amsOwnUserAssetAuthorityMapper.selectAmsOwnUserAssetAuthorityList(amsOwnUserAssetAuthority);
    }

    /**
     * 新增物联网资产设备用户权限信息
     * 
     * @param amsOwnUserAssetAuthority 物联网资产设备用户权限信息
     * @return 结果
     */
    @Override
    public int insertAmsOwnUserAssetAuthority(AmsOwnUserAssetAuthority amsOwnUserAssetAuthority)
    {

        amsOwnUserAssetAuthority.setCreateTime(System.currentTimeMillis());
        amsOwnUserAssetAuthority.setCreateBy(SecurityUtils.getUsername());
        return amsOwnUserAssetAuthorityMapper.insertAmsOwnUserAssetAuthority(amsOwnUserAssetAuthority);
    }

    /**
     * 修改物联网资产设备用户权限信息
     * 
     * @param amsOwnUserAssetAuthority 物联网资产设备用户权限信息
     * @return 结果
     */
    @Override
    public int updateAmsOwnUserAssetAuthority(AmsOwnUserAssetAuthority amsOwnUserAssetAuthority)
    {
        amsOwnUserAssetAuthority.setUpdateTime(System.currentTimeMillis());
        amsOwnUserAssetAuthority.setUpdateBy(SecurityUtils.getUsername());
        return amsOwnUserAssetAuthorityMapper.updateAmsOwnUserAssetAuthority(amsOwnUserAssetAuthority);
    }

    /**
     * 批量删除物联网资产设备用户权限信息
     * 
     * @param ownUserAssetAuthorityIds 需要删除的物联网资产设备用户权限信息主键
     * @return 结果
     */
    @Override
    public int deleteAmsOwnUserAssetAuthorityByOwnUserAssetAuthorityIds(Long[] ownUserAssetAuthorityIds)
    {
        return amsOwnUserAssetAuthorityMapper.deleteAmsOwnUserAssetAuthorityByOwnUserAssetAuthorityIds(ownUserAssetAuthorityIds);
    }

    /**
     * 删除物联网资产设备用户权限信息信息
     * 
     * @param ownUserAssetAuthorityId 物联网资产设备用户权限信息主键
     * @return 结果
     */
    @Override
    public int deleteAmsOwnUserAssetAuthorityByOwnUserAssetAuthorityId(Long ownUserAssetAuthorityId)
    {
        return amsOwnUserAssetAuthorityMapper.deleteAmsOwnUserAssetAuthorityByOwnUserAssetAuthorityId(ownUserAssetAuthorityId);
    }

    @Override
    public List<ApplyUnlockAuthVo> getApplyInfoByGrantId(Long grantUserId) {
        return amsOwnUserAssetAuthorityMapper.getApplyInfoByGrantId(grantUserId,null);
    }

    @Override
    public List<ApplyHistoryInifo> getApplyHistoryInfos(Long userId) {
        return amsOwnUserAssetAuthorityMapper.getApplyHistoryInfos(userId);
    }

    @Override
    public List<ApplyUnlockAuthVo> getApplyInfoByDeptId(Long deptId, Integer status) {
        return amsOwnUserAssetAuthorityMapper.getApplyInfoByDeptId(deptId,status);
    }
}
